/***************************************************************************
 创建者：       hualei
 开始时间：    2018.09.10
 copyright:(C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************/
#include "movemaginstructiondelegate.h"
#include <QDebug>

MoveMagInstructionDelegate::MoveMagInstructionDelegate(QWidget *parent) :
    QObject(parent)
{
}
void MoveMagInstructionDelegate::initView()
{
   moveMagInstructionView->leftMiddleRight = 1;
   moveMagInstructionView->frontBack = 0;
   moveMagInstructionView->annotationStr = "";
   moveMagInstructionView->rfidValue = '0';
   moveMagInstructionView->velocityRatio = 0;
   moveMagInstructionView->stopInputNum = 0;


}

void MoveMagInstructionDelegate::clearNoteSlot()
{
    moveMagInstructionView->annotationStr.clear();

    qDebug("Clear Note!");
}

void MoveMagInstructionDelegate::finishEditInstructionSlot()
{
    QString str = "MOVE_MAG";
    QString leftMiddleRight;
    QString frontBack;
    if(moveMagInstructionView->leftMiddleRight == 0)
    {
        leftMiddleRight = " L ";
    }
    else if(moveMagInstructionView->leftMiddleRight == 1)
    {
        leftMiddleRight = " M ";
    }
    else if(moveMagInstructionView->leftMiddleRight == 2)
    {
        leftMiddleRight = " R ";
    }
    moveMagInstructionView->instruction = str + leftMiddleRight;

    if(moveMagInstructionView->frontBack == 0)
    {
        frontBack = "FRONT ";
    }
    else if(moveMagInstructionView->frontBack == 1)
    {
        frontBack = "BACK ";
    }

    moveMagInstructionView->instruction += frontBack;
    moveMagInstructionView->instruction += QString("%1").arg(moveMagInstructionView->velocityRatio)+"%,";

    moveMagInstructionView->instruction += +"RFID " + moveMagInstructionView->rfidValue;
    if(moveMagInstructionView->stopType == E_MOVE_MAG_INPUT_STOP)
    {
        moveMagInstructionView->instruction += "," + tr("INPUT ") + QString::number(moveMagInstructionView->stopInputNum);
    }
    else if(moveMagInstructionView->stopType == E_MOVE_MAG_RFID_STOP)
    {
        moveMagInstructionView->instruction += "," + tr("RFID_STOP");
    }
    else if(moveMagInstructionView->stopType == E_MOVE_MAG_MAG_WIDTH_STOP)
    {
        moveMagInstructionView->instruction += "," + tr("MAG_STOP");
    }

    moveMagInstructionView->instruction += "  //" + moveMagInstructionView->annotationStr;

}
